package newsletterApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/model/request"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type StockBulletinController struct{}

// GetStockBulletin 多条件查询
// @Summary stockBulletin get
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockBulletinModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/getStockBulletin [GET]
func (b *StockBulletinController) GetStockBulletin(c *gin.Context) {
	var req model.StockBulletinModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "GetStockBulletin", req, c)
		return
	}
	apiReturn := stockBulletinService.GetStockBulletin(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockBulletin
// @Summary stockBulletin insert
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockBulletinModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/InsertStockBulletin [POST]
func (b *StockBulletinController) InsertStockBulletin(c *gin.Context) {
	var req request.InsertBulletinRequest
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "InsertStockBulletin", req, c)
		return
	}
	apiReturn := stockBulletinService.InsertStockBulletin(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockBulletin
// @Summary stockBulletin update
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockBulletinModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/updateStockBulletin [POST]
func (b *StockBulletinController) UpdateStockBulletin(c *gin.Context) {
	var req model.StockBulletinModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "UpdateStockBulletin", req, c)
		return
	}
	apiReturn := stockBulletinService.UpdateStockBulletin(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockBulletin
// @Summary stockBulletin del
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockBulletinModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/delStockBulletin [Get]
func (b *StockBulletinController) DelStockBulletin(c *gin.Context) {
	var req model.StockBulletinModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "DelStockBulletin", req, c)
		return
	}
	apiReturn := stockBulletinService.DelStockBulletin(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
